---
title: "Prompts"
description: "Building prompt templates for AI model interactions"
icon: "message-square"
---

Prompts in MCP provide a way to create reusable, parameterized templates for AI model interactions. They enable standardized prompt generation with dynamic content based on user-provided arguments.


## Prompt Structure

Every prompt has three main components:

```typescript
server.prompt({
  name: 'prompt_name',              // Unique identifier
  description: 'What it generates',  // Clear description
  schema: z.object({...}),                 // Argument definitions
}, async (args) => {...}) // generator function
```

## Input Validation with Zod

Prompts use [Zod](https://zod.dev/) schemas for input validation. The server automatically validates inputs before calling your handler, so you can trust that the parameters match your schema.

```typescript
import { z } from 'zod';

server.prompt({
  name: 'prompt_name',
  description: 'What it generates',
  schema: z.object({
    topic: z.enum(['math', 'science', 'history']),
    language: z.string().default('english'),
    ok: z.boolean()
  }),
}, async ({ topic }) => {
  return {
    messages: [
      {
        role: 'system',
        content: `You are a helpful assistant that can answer questions about ${topic}.`
      }
    ]
  }
})
```

## Next Steps

- [Tools Guide](./tools) - Building executable tools
- [Resources Guide](./resources) - Managing content
- [API Reference](./api-reference) - Complete API documentation
- [Examples](./examples) - Real-world implementations